//
//  PersonNameView.m
//  PlayCatchGame
//
//  Created by 流言 on 2018/2/8.
//  Copyright © 2018年 清正. All rights reserved.
//

#import "PersonNameView.h"
#import "IQKeyboardManager.h"

@interface PersonNameView()

@property (nonatomic, copy)ButtonBlock buttonBlock;

@end

@implementation PersonNameView

- (void)awakeFromNib {
    [super awakeFromNib];
    [IQKeyboardManager sharedManager].enable =NO;
    [self.nameTF becomeFirstResponder];
}

- (IBAction)buttonClick:(UIButton *)sender {
    if (self.buttonBlock) {
        if ([self.nameTF isFirstResponder]) {
            [self.nameTF resignFirstResponder];
            /// 延迟 等待下键盘完成
            [TimerHandler performAfterDelay:0.4 handler:^{
                self.buttonBlock(sender);
            }];
        } else {
            self.buttonBlock(sender);
        }
    }
}

- (void)removeFromSuperview {
    [super removeFromSuperview];
    [IQKeyboardManager sharedManager].enable =YES;
}

- (void)didButtonClick:(ButtonBlock)newBlock {
    self.buttonBlock = newBlock;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
